package com.bocai.yuweiwangluo.activity;


import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;

import com.bocai.yuweiwangluo.R;
import com.bocai.yuweiwangluo.base.BaseActivity;
import com.bocai.yuweiwangluo.presenter.ChangePwdPresenter;
import com.bocai.yuweiwangluo.viewModel.IChangePwdView;
import com.lidroid.xutils.ViewUtils;
import com.lidroid.xutils.view.annotation.ViewInject;

/**
 * 忘记密码界面
 */
public class ForgetPsdActivity extends BaseActivity implements View.OnClickListener,IChangePwdView
{
    @ViewInject(R.id.btn_forgetpwd_getcode)
    Button btnGetcode;
    @ViewInject(R.id.et_forgetpwd_tel)
    EditText etTel;
    @ViewInject(R.id.et_forgetpwd_code)
    EditText etCode;
    @ViewInject(R.id.btn_forgetpwd_next)
    Button btnNext;
    @ViewInject(R.id.ll_changepwd_getcode)
    LinearLayout ll_getcode;
    @ViewInject(R.id.ll_changepwd_setpwd)
    LinearLayout ll_setpwd;
    @ViewInject(R.id.et_changepwd_pwd)
    EditText etpwd;
    @ViewInject(R.id.et_changepwd_pwdtrue)
    EditText etpwdtrue;
    @ViewInject(R.id.btn_changepwd_next)
    Button btnChangepwdNext;
    private ChangePwdPresenter changePwdPresenter;
    @Override
    protected int contentView()
    {
        return R.layout.activity_forget_psd;
    }

    @Override
    protected void setData()
    {
        ViewUtils.inject(this);
        initToolbar("忘记密码");
        getChangePwdPresenter();
        initEvent();
    }

    @Override
    protected void initEvent()
    {
        super.initEvent();
        btnGetcode.setOnClickListener(this);
        btnNext.setOnClickListener(this);
        btnChangepwdNext.setOnClickListener(this);
    }


    @Override
    public void onClick(View v)
    {
        switch (v.getId())
        {
            case R.id.btn_forgetpwd_getcode:
                //获取验证码
                changePwdPresenter.getCode();
                break;
            case R.id.btn_forgetpwd_next:
                //验证验证码
                changePwdPresenter.verificationCode();
                break;
            case R.id.btn_changepwd_next:
                //修改密码
                changePwdPresenter.changePwd();
                break;
        }
    }

    @Override
    public String getTel()
    {
        return etTel.getText().toString();
    }

    @Override
    public String getCode()
    {
        return etCode.getText().toString();
    }

    @Override
    public String getPwd()
    {
        return etpwd.getText().toString();
    }

    @Override
    public String getPwdtrue()
    {
        return etpwdtrue.getText().toString();
    }

    @Override
    public ChangePwdPresenter getChangePwdPresenter()
    {
        changePwdPresenter=new ChangePwdPresenter(this,this,this,btnGetcode);
        return changePwdPresenter;
    }

    @Override
    public LinearLayout getLLChangepwd()
    {
        return ll_setpwd;
    }

    @Override
    public LinearLayout getLLGetCode()
    {
        return ll_getcode;
    }

    @Override
    public void finishActivity()
    {
        this.finish();
    }
}
